﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using TimKen.DataEntity;
using TimKen.BussLogic;

namespace TimKen.Web.Admin.WebUser
{
    public partial class WebUser_List : TimKen.App.AdminPage
    {
        WebUserManager wum = new WebUserManager();
        public override string ActionCode
        {
            get
            {
                return "84";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
                BindResources();
            }
        }
        public void BindResources()
        {
            btnSearch.Text = GetLangString("Search");
        }

        protected void BindData()
        {
            DataSet ds = wum.GetPageList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, txtUserName.Text, txtRealName.Text, txtCompany.Text);
            AspNetPager1.RecordCount = Convert.ToInt32(ds.Tables[1].Rows[0]["total"]);
            this.grdWebUser.DataSource = ds;
            this.grdWebUser.DataBind();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 0;
            BindData();
        }

        protected void grdWebUser_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string userID = e.CommandArgument.ToString();

            if (e.CommandName == "DeleteEvent")
            {
                wum.Delete(userID);
                BindData();
            }

        }
    }
}
